USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[DealersClassifications-Insert]    Script Date: [[20120914064953]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064953]]
-- Description:	Insert record into table [dbo].[DealersClassifications]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[DealersClassifications-Insert]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[DealersClassifications-Insert]*/
GO
-- =============================================
Create PROCEDURE [dbo].[DealersClassifications-Insert]
	/*@DealerClassification_RowNumber int =Null OUTPUT , 
	@DealerClassification_ID uniqueidentifier =Null  , 
	@DealerClassification_Code varchar(50) =Null  , 
	@DealerType_ID uniqueidentifier =Null  , 
	@DealerClassification_NameAr varchar(300) =Null  , 
	@DealerClassification_NameEn varchar(300) =Null  , 
	@DealerClassification_Notes varchar(max) =Null  , 
	@DealerClassification_Search varchar(max) =Null  , 
	@DealerClassification_TimeStamp timestamp =Null OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	INSERT  INTO [dbo].[DealersClassifications](/*[DealerClassification_ID], [DealerClassification_Code], [DealerType_ID], [DealerClassification_NameAr], [DealerClassification_NameEn], [DealerClassification_Notes], [DealerClassification_Search]*/)
	VALUES     (/*@DealerClassification_ID, @DealerClassification_Code, @DealerType_ID, @DealerClassification_NameAr, @DealerClassification_NameEn, @DealerClassification_Notes, @DealerClassification_Search*/)

	/*SELECT @DealerClassification_RowNumber = [DealerClassification_RowNumber], @DealerClassification_TimeStamp = [DealerClassification_TimeStamp]
    FROM [dbo].[DealersClassifications]
    WHERE  ( [DealerClassification_ID] =@DealerClassification_ID )
	AND  ( [DealerClassification_Code] =@DealerClassification_Code )
	AND  ( [DealerType_ID] =@DealerType_ID )
	AND  ( [DealerClassification_NameAr] =@DealerClassification_NameAr )
	AND  ( [DealerClassification_NameEn] =@DealerClassification_NameEn )
	AND  ( [DealerClassification_Notes] =@DealerClassification_Notes )
	AND  ( [DealerClassification_Search] =@DealerClassification_Search )*/
END
GO
-- =============================================
USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[DealersClassifications-update]    Script Date: [[20120914064953]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064953]]
-- Description:	Update record in table [dbo].[DealersClassifications]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[DealersClassifications-update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[DealersClassifications-update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[DealersClassifications-update]
	/*@DealerClassification_RowNumber int =Null OUTPUT , 
	@DealerClassification_ID uniqueidentifier =Null  , 
	@DealerClassification_Code varchar(50) =Null  , 
	@DealerType_ID uniqueidentifier =Null  , 
	@DealerClassification_NameAr varchar(300) =Null  , 
	@DealerClassification_NameEn varchar(300) =Null  , 
	@DealerClassification_Notes varchar(max) =Null  , 
	@DealerClassification_Search varchar(max) =Null  , 
	@DealerClassification_TimeStamp timestamp =Null OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	/*SELECT @OldTimeStamp = [DealerClassification_TimeStamp]
    FROM [dbo].[DealersClassifications]
    	WHERE ([DealerClassification_ID] = @DealerClassification_ID)

    IF  @OldTimeStamp = @DealerClassification_TimeStamp
    BEGIN*/
		Update [dbo].[DealersClassifications] SET 
		/*[DealerClassification_ID] =@DealerClassification_ID, 
		[DealerClassification_Code] =@DealerClassification_Code, 
		[DealerType_ID] =@DealerType_ID, 
		[DealerClassification_NameAr] =@DealerClassification_NameAr, 
		[DealerClassification_NameEn] =@DealerClassification_NameEn, 
		[DealerClassification_Notes] =@DealerClassification_Notes, 
		[DealerClassification_Search] =@DealerClassification_Search*/
		/*WHERE ([DealerClassification_ID] = @DealerClassification_ID)*/
	/*END*/

	/*SELECT @DealerClassification_RowNumber = [DealerClassification_RowNumber], @DealerClassification_TimeStamp = [DealerClassification_TimeStamp]
    FROM [dbo].[DealersClassifications]
	WHERE ([DealerClassification_ID] = @DealerClassification_ID)*/
END
GO
-- =============================================
USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[DealersClassifications-Insert-Update]    Script Date: [[20120914064953]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064953]]
-- Description:	Insert OR Update record into table [dbo].[DealersClassifications]
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[DealersClassifications-Insert-Update]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[DealersClassifications-Insert-Update]*/
GO
-- =============================================
Create PROCEDURE [dbo].[DealersClassifications-Insert-Update]
	/*@DealerClassification_RowNumber int =Null OUTPUT , 
	@DealerClassification_ID uniqueidentifier =Null  , 
	@DealerClassification_Code varchar(50) =Null  , 
	@DealerType_ID uniqueidentifier =Null  , 
	@DealerClassification_NameAr varchar(300) =Null  , 
	@DealerClassification_NameEn varchar(300) =Null  , 
	@DealerClassification_Notes varchar(max) =Null  , 
	@DealerClassification_Search varchar(max) =Null  , 
	@DealerClassification_TimeStamp timestamp =Null OUTPUT , 
	@Inserted bit OUTPUT , 
	@OldTimeStamp timeStamp OUTPUT*/ 
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;
	IF NOT EXISTS (SELECT * FROM [dbo].[DealersClassifications] 
					/*WHERE ([DealerClassification_ID] = @DealerClassification_ID)*/)
	BEGIN
		
		INSERT  INTO [dbo].[DealersClassifications](/*[DealerClassification_ID], [DealerClassification_Code], [DealerType_ID], [DealerClassification_NameAr], [DealerClassification_NameEn], [DealerClassification_Notes], [DealerClassification_Search]*/)
		VALUES     (/*@DealerClassification_ID, @DealerClassification_Code, @DealerType_ID, @DealerClassification_NameAr, @DealerClassification_NameEn, @DealerClassification_Notes, @DealerClassification_Search*/)

		SET /*@*/Inserted=1
	END
	ELSE
	BEGIN
		
		/*SELECT @OldTimeStamp = [DealerClassification_TimeStamp]
		FROM [dbo].[DealersClassifications]
    	WHERE ([DealerClassification_ID] = @DealerClassification_ID)

		IF  @OldTimeStamp = @DealerClassification_TimeStamp
		BEGIN*/
			Update [dbo].[DealersClassifications] SET 
			/*[DealerClassification_ID] =@DealerClassification_ID, 
			[DealerClassification_Code] =@DealerClassification_Code, 
			[DealerType_ID] =@DealerType_ID, 
			[DealerClassification_NameAr] =@DealerClassification_NameAr, 
			[DealerClassification_NameEn] =@DealerClassification_NameEn, 
			[DealerClassification_Notes] =@DealerClassification_Notes, 
			[DealerClassification_Search] =@DealerClassification_Search*/
			/*WHERE ([DealerClassification_ID] = @DealerClassification_ID)*/
		/*END*/
		
		SET /*@*/Inserted=0
	END

	/*SELECT @DealerClassification_RowNumber = [DealerClassification_RowNumber], @DealerClassification_TimeStamp = [DealerClassification_TimeStamp]
    FROM [dbo].[DealersClassifications]
	WHERE ([DealerClassification_ID] = @DealerClassification_ID)*/
END
GO
-- =============================================
USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[DealersClassifications-Delete]    Script Date: [[20120914064953]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064953]]
-- Description:	delete records from table [dbo].[DealersClassifications] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[DealersClassifications-Delete]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[DealersClassifications-Delete]*/
GO
-- =============================================
Create PROCEDURE [dbo].[DealersClassifications-Delete]
	/*@DealerClassification_RowNumber int =null  , 
	@DealerClassification_ID uniqueidentifier =null  , 
	@DealerClassification_Code varchar(50) =null  , 
	@DealerType_ID uniqueidentifier =null  , 
	@DealerClassification_NameAr varchar(300) =null  , 
	@DealerClassification_NameEn varchar(300) =null  , 
	@DealerClassification_Notes varchar(max) =null  , 
	@DealerClassification_Search varchar(max) =null  , 
	@DealerClassification_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	Delete FROM  [dbo].[DealersClassifications]
	WHERE /*( [DealerClassification_RowNumber] = ISNULL(@DealerClassification_RowNumber, [DealerClassification_RowNumber]) )
	AND ( [DealerClassification_ID] = ISNULL(@DealerClassification_ID, [DealerClassification_ID]) )
	AND ( [DealerClassification_Code] like ISNULL(@DealerClassification_Code, [DealerClassification_Code]) )
	AND ( [DealerType_ID] = ISNULL(@DealerType_ID, [DealerType_ID]) )
	AND ( [DealerClassification_NameAr] like ISNULL(@DealerClassification_NameAr, [DealerClassification_NameAr]) )
	AND ( [DealerClassification_NameEn] like ISNULL(@DealerClassification_NameEn, [DealerClassification_NameEn]) )
	AND ( [DealerClassification_Notes] like ISNULL(@DealerClassification_Notes, [DealerClassification_Notes]) )
	AND ( [DealerClassification_Search] like ISNULL(@DealerClassification_Search, [DealerClassification_Search]) )
	AND ( [DealerClassification_TimeStamp] = ISNULL(@DealerClassification_TimeStamp, [DealerClassification_TimeStamp]) )*/
END
GO
-- =============================================
USE [CustomersSuppliers]
/****** Object:  StoredProcedure [dbo].[DealersClassifications-Select]    Script Date: [[20120914064953]] ******/
-- =============================================
-- Author:		Ahmed Fathi Hamouda Abd El Hafez
-- Create date: [[20120914064953]]
-- Description:	select records from table [dbo].[DealersClassifications] based on optional Conditions
-- =============================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*IF EXISTS (SELECT * FROM dbo.Sysobjects where id = object_id(N'[dbo].[DealersClassifications-Select]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
   drop procedure [dbo].[DealersClassifications-Select]*/
GO
-- =============================================
Create PROCEDURE [dbo].[DealersClassifications-Select]
	/*@DealerClassification_RowNumber int =null  , 
	@DealerClassification_ID uniqueidentifier =null  , 
	@DealerClassification_Code varchar(50) =null  , 
	@DealerType_ID uniqueidentifier =null  , 
	@DealerClassification_NameAr varchar(300) =null  , 
	@DealerClassification_NameEn varchar(300) =null  , 
	@DealerClassification_Notes varchar(max) =null  , 
	@DealerClassification_Search varchar(max) =null  , 
	@DealerClassification_TimeStamp timestamp =null*/
AS
BEGIN
	--SET NOCOUNT ON added to prevent extra result sets from
	--interfering with SELECT statements.
	SET NOCOUNT ON;

	SELECT * FROM  [dbo].[DealersClassifications]
	WHERE /*( [DealerClassification_RowNumber] = ISNULL(@DealerClassification_RowNumber, [DealerClassification_RowNumber]) )
	AND ( [DealerClassification_ID] = ISNULL(@DealerClassification_ID, [DealerClassification_ID]) )
	AND ( [DealerClassification_Code] like ISNULL(@DealerClassification_Code, [DealerClassification_Code]) )
	AND ( [DealerType_ID] = ISNULL(@DealerType_ID, [DealerType_ID]) )
	AND ( [DealerClassification_NameAr] like ISNULL(@DealerClassification_NameAr, [DealerClassification_NameAr]) )
	AND ( [DealerClassification_NameEn] like ISNULL(@DealerClassification_NameEn, [DealerClassification_NameEn]) )
	AND ( [DealerClassification_Notes] like ISNULL(@DealerClassification_Notes, [DealerClassification_Notes]) )
	AND ( [DealerClassification_Search] like ISNULL(@DealerClassification_Search, [DealerClassification_Search]) )
	AND ( [DealerClassification_TimeStamp] = ISNULL(@DealerClassification_TimeStamp, [DealerClassification_TimeStamp]) )*/
END
GO
-- =============================================
